package com.cqc.manage.repositories;

import com.cqc.manage.entity.Business;
import com.cqc.manage.entity.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface BusinessRepositories extends JpaRepository<Business,String>, JpaSpecificationExecutor<Business> {

    /**
     * 通过合同编号查询
     * @param contractNo
     * @return
     */
    public Business findByContractNo(String contractNo);

    /**
     * 分页查询
     * @param pageable
     * @return
     */
    Page<Business> findAll(Pageable pageable);

    @Query(nativeQuery = true,value ="SELECT * from business where business.flat = TRUE")
    Page<Business> getAll(Pageable pageable);


    @Query(nativeQuery = true ,value = "select business.contract_no from business")
    List<String> getAllContractNo();


    List<String> queryAllBy();
}
